package top.IT00544.novel.entity;

import net.sf.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * 后台传递到前台的数据对象
 */
public class JsonMsg {

    public static final String STATUS_OK="ok";
    public static final String STATUS_ERR="err";
    /**提示信息*/
    private String message=STATUS_OK;
    /**状态 ok:没问题，err:有问题*/
    private String status = STATUS_OK;
    /**数据对象*/
    private HashMap data = new HashMap();

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public HashMap getData() {
        return data;
    }

    public void setData(HashMap data) {
        this.data = data;
    }

    public void putData(Novel nov){
        this.data.put("data",nov);
    }
    public void putData(ArrayList<Novel> novels){
        this.data.put("data",novels);
    }

    public String toJsonString(){
        JSONObject jsonObject = new JSONObject();
        String str = jsonObject.fromObject(this).toString();
        return str;
    }
}
